import { createApp } from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import antd from 'ant-design-vue'
import 'ant-design-vue/dist/antd.css'
import {isEmpty} from "@/util/Tool"
import axios from "axios";

createApp(App).use(store).use(router).use(antd).mount('#app')

// axios 拦截器
axios.interceptors.request.use(
    (config)=>{
        // console.log("请求参数",config)
        const token = store.state.user.token
        if (!isEmpty(token)) {
            config.headers.token = token
        }
        return config
    },
    (error)=>{
        return Promise.reject(error)
    }
)

axios.interceptors.response.use(
    (response)=>{
        // console.log("返回结果",response)
        return response
    },
    error => {
        // console.log("返回错误",error)
        return Promise.reject(error)
    }
)